package com.spring.courseapi.web.controller;



import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.fasterxml.jackson.databind.util.JSONPObject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mangofactory.swagger.annotations.ApiIgnore;
import com.spera.genutil.TokenUtil;
import com.spring.comment.web.service.CommentService;
import com.spring.common.web.requestModel.ProductPromotion;
import com.spring.courseapi.web.requestModel.Register;
import com.spring.courseapi.web.service.CourseApiService;
import com.spring.courseapi.web.service.GameService;
import com.spring.security.core.util.ApplicationUtils;
import com.spring.security.web.controller.BaseController;
import com.spring.security.web.dao.JedisCache;
import com.spring.security.web.model.BaseResult;
import com.wordnik.swagger.annotations.ApiOperation;
@Controller
@RequestMapping(value = "/gameCourse")

public class GameCourseController extends BaseController{

	@Resource
	private JedisCache jedisCache;
	
	@Resource
	private GameService gameService;

	//注册家长用户
	@RequestMapping(value = "/register",method=RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "注册用户", httpMethod = "POST", response = Object.class, notes = "注册用户",produces = "application/json; charset=utf-8")
    public Object register(Register register,String course_open_detailID) {
   
		BaseResult br = null;
		try {
			
			br=gameService.register(register, course_open_detailID);
			//m  = gameService.register(register);
					
		} catch (Exception e) {
    		e.printStackTrace();
			return buildFailedResultInfo("系统异常",register.getCallback());	
		}
        	return br;   
    }
	
	
	//注册家长用户
	@RequestMapping(value = "/family",method=RequestMethod.GET)
	@ResponseBody
	@ApiOperation(value = "查询用户", httpMethod = "GET", response = Object.class, notes = "查询用户",produces = "application/json; charset=utf-8")
    public Object family(@RequestParam String phone,String callback) {
   
		BaseResult br = null;
		try {
			
			br=gameService.family(phone);
			//m  = gameService.register(register);
					
		} catch (Exception e) {
    		e.printStackTrace();
			return buildFailedResultInfo("系统异常",callback);	
		}
        	return br;   
    }

	
	//预约课程
	@RequestMapping(value = "/courseAppointment",method=RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "查询用户", httpMethod = "POST", response = Object.class, notes = "查询用户",produces = "application/json; charset=utf-8")
    public Object courseAppointment(@RequestParam String course_open_detailID,
    		@RequestParam String babies,String callback) {
   
		BaseResult br = null;
		try {
			
			br=gameService.courseAppointment(course_open_detailID, babies);
			//m  = gameService.register(register);
					
		} catch (Exception e) {
    		e.printStackTrace();
			return buildFailedResultInfo("系统异常",callback);	
		}
        	return br;   
    }
	

	 
		//取消课程
		@RequestMapping(value = "/cancelCourseAppointment",method=RequestMethod.POST)
		@ResponseBody
		@ApiOperation(value = "取消课程", httpMethod = "POST", response = Object.class, notes = "取消课程",produces = "application/json; charset=utf-8")
	    public Object cancelCourseAppointment(@RequestParam String course_open_detailID,
	    		@RequestParam String c_user_id,String callback) {
	   
			BaseResult br = null;
			try {
				
				br=gameService.cancelCourseAppointment(course_open_detailID, c_user_id);
				//m  = gameService.register(register);
						
			} catch (Exception e) {
	    		e.printStackTrace();
				return buildFailedResultInfo("系统异常",callback);	
			}
	        	return br;   
	    }
				
		
		@RequestMapping(value = "/todayFamily",method=RequestMethod.GET)
		@ResponseBody
		@ApiOperation(value = "查询当天付款用户", httpMethod = "GET", response = Object.class, notes = "查询用户",produces = "application/json; charset=utf-8")
	    public Object todayFamily(String skip, String rows,String callback) {
	   
			BaseResult br = null;
			try {
				
				br=gameService.todayFamily(skip, rows);
						
			} catch (Exception e) {
	    		e.printStackTrace();
				return buildFailedResultInfo("系统异常",callback);	
			}
	        	return br;   
	    }
}

